<template>
	<view class="order">
		<!-- 列表 -->
		<view class="listBox">
			<view class="list" v-for="(item,index) in list" :key="index" @tap.stop="toPdf(item)">
				<view class="list_t">
					<view class="box">
						<image src="@/static/my/bell.png" mode="widthFix"></image>
						<u-text :text="item.filename" lines="1" line-height="48rpx" color="#000" size="28rpx" />
					</view>
					<view class="box">
						<image src="@/static/my/time.png" mode="widthFix"></image>
						<view class="name" style="color: #B6B6B6;">{{item.uploadtime}}</view>
					</view>
				</view>
			</view>
		</view>
		<view style="width: 100%; text-align: center; font-size: 28rpx; margin-top: 100rpx;">{{isText}}
		</view>
	</view>
</template>

<script>
	import {
		getFile
	} from "@/request/homeApi.js";
	import brl from "@/request/baseUrl.js"
	export default {
		data() {
			return {
				page: 1,
				list: [],
				isText: '',
				last_page: 1,
				type: 1,
				id: ''
			};
		},
		onLoad(e) {
			this.id = e.id
			this.getList()
		},
		// onReachBottom() {
		// 	let that = this
		// 	if (that.page < that.last_page) {
		// 		that.page = that.page + 1
		// 		that.getList()
		// 	}
		// },
		onShow() {
			this.list = []
			// this.page = 1
			this.isText = ''
			this.getList()
		},
		methods: {
			// 报价方案
			toPdf(files) {
				let name = files.filename
				console.log(name,'name')
				if (files.url != '' && files.url != null) {
					this.pdfUrl = brl.baseUrl + files.url
					setTimeout(() => {
						uni.getSystemInfo({
							success: res => {
								wx.downloadFile({
									url: this.pdfUrl,
									// filePath: wx.env.USER_DATA_PATH + `${name}`,
									success: function(res) {
										console.log(res, 'this.pdfUrl');
										wx.openDocument({
											showMenu: true,
											filePath: res.tempFilePath,
											success: function(
												res) {
												console.log(
													'打开文档成功'
												);
											}
										});
									}
								});
							}
						});
					}, 500)
				} else {
					uni.showToast({
						title: '暂无',
						duration: 1500,
						icon: 'none',
					})
				}
			},
			// 获取订单列表
			getList() {
				let that = this
				// that.list = [{
				// 	title: 'xxxxx',
				// 	createtime: '2017-05-14'
				// }, {
				// 	title: 'xxxxx',
				// 	createtime: '2017-05-14'
				// }, {
				// 	title: 'xxxxx',
				// 	createtime: '2017-05-14'
				// }, {
				// 	title: 'xxxxx',
				// 	createtime: '2017-05-14'
				// }]
				// return
				getFile({
					id: that.id,
				}).then((res) => {
					if (res.code == 200) {
						res.data.length == 0 ? that.isText = '暂无数据' : that.isText = ''
						that.list = res.data ? res.data : []
						// that.list = that.list.concat(res.data)
						// that.last_page = Math.ceil(res.data.count / res.data.list.length)
					} else {
						uni.showToast({
							title: res.msg,
							duration: 1500,
							icon: 'none',
						})
					}
				});
			},
		},
	}
</script>

<style lang="less">
	page {
		// background-color: #f9f9f9;
	}

	.u-tab-bar {
		display: none !important;
	}

	.chooseCup {
		margin-right: 8rpx !important;

		image {
			width: 20rpx !important;
			height: 12rpx !important;
			margin: 14rpx;
		}
	}

	.order {
		width: 100vw;

		.tabBox {
			width: 100%;
			// height: 100rpx;
		}

		.listBox {
			width: 95%;
			margin: 20rpx auto;

			.list {
				width: 100%;
				height: auto;
				padding: 20rpx;
				border-radius: 20rpx;
				background-color: #fff;
				// margin: 20rpx auto;
				box-sizing: border-box;
				display: flex;
				justify-content: space-between;
				border-bottom: 2rpx solid rgba(217, 217, 217, 0.4);

				.code {
					color: #979797;
					font-weight: 400;
					font-size: 12px;
					line-height: 17px;
					margin-bottom: 10rpx;
				}

				.list_t {
					view {
						display: flex;
						flex: 1;
						justify-content: space-between;
						align-items: center;
					}

					.box {
						height: 50rpx;
						line-height: 50rpx;
						font-size: 30rpx;

						image {
							width: 28rpx;
							border-radius: 50%;
							margin-right: 14rpx;
						}

						.name {
							font-size: 26rpx;
						}
					}
				}

				.list_b {
					font-size: 28rpx;
					font-weight: 400;
					color: #7F8084;
					padding-top: 30rpx;

					.text {
						.money {
							display: inline-block;
							font-size: 32rpx;
							font-weight: 600;
							color: #000;
						}
					}
				}

				.btnBox {
					width: 100%;
					margin-top: 30rpx;
					flex-direction: row-reverse !important;

					.btn {
						width: 132rpx;
						height: 46rpx;
						line-height: 46rpx;
						border-radius: 46rpx;
						text-align: center;
						background-color: #000;
						color: #fff;
						font-size: 24rpx;
						font-weight: 500;
					}
				}

			}
		}
	}
</style>